package com.cqc.crm.dao.impl;

import java.io.Serializable;
import java.util.List;

import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import com.cqc.crm.dao.UserDao;
import com.cqc.crm.domain.User;

public class UserDaoImpl extends HibernateDaoSupport implements UserDao {

	@Override
	public List<User> findUserByUserName(String user_code) {
		List<User> list = (List<User>) getHibernateTemplate().find("from User where user_code = ?", user_code);
		return list;
	}

	@Override
	public void save(User user) {
//		getHibernateTemplate().saveOrUpdate(user);
		Serializable serializable = getHibernateTemplate().save(user);
		//返回user的id
		System.out.println("serializable="+serializable);
	}

	@Override
	public List<User> login(User user) {
		List<User> list = (List<User>) getHibernateTemplate().find("from User where user_code=? and user_password=?", user.getUser_code(),user.getUser_password());
		return list;
	}

}
